import request from '@/utils/request'

export function getAccountList(playload) {
  return request({
    url: '/get',
    method: 'get',
    params: {
      module: 'UserService.view',
      ...playload
    }
  })
}

export function getRoleList(playload) {
  return request({
    url: '/get',
    method: 'get',
    params: {
      module: 'SystemService.viewGroup',
      ...playload
    }
  })
}

export function getConfigList(playload) {
  return request({
    url: '/get',
    method: 'get',
    params: {
      module: 'SystemService.viewConfigs',
      ...playload
    }
  })
}

export function getViewRoleList(playload) {
  return request({
    url: '/get',
    params: {
      module: 'SystemService.viewRole',
      ...playload
    },
    method: 'get'
  })
}

export function editAccountList(playload) {
  let module_name = 'UserService.add'
  if (playload.id && playload.id !== '') {
    module_name = 'UserService.update'
  }

  const data = {
    module: module_name,
    ...playload
  }

  return request({
    url: '/post',
    method: 'post',
    data
  })
}

export function editConfigList(playload) {
  let module_name = 'SystemService.updateConfigs'
  if (playload.key0) {
    module_name = 'SystemService.addConfig'
  }

  const data = {
    module: module_name,
    ...playload
  }

  return request({
    url: '/post',
    method: 'post',
    data
  })
}
